package com.rain.shoppingscienceproj.utils;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

import picker.prim.com.primpicker_core.engine.ImageEngine;

/**
 * Author: Rain
 * Create: 2018/9/3 4:33
 */
public class ImageLoader implements ImageEngine {

    @Override
    public void loadImageThumbnail(Context context, int resize, Drawable placeholder, ImageView view, Uri uri) {
        Glide.with(context).load(uri).asBitmap().placeholder(placeholder).override(resize, resize).centerCrop().into(view);
    }

    @Override
    public void loadImage(Context context, int resizeX, int resizeY, Drawable placeholder, ImageView view, Uri uri) {
        Glide.with(context).load(uri).asBitmap().placeholder(placeholder).override(resizeX, resizeY).fitCenter().into(view);
    }

    @Override
    public void loadGifThumbnail(Context context, int resize, Drawable placeholder, ImageView view, Uri uri) {
        Glide.with(context).load(uri).asGif().placeholder(placeholder).override(resize, resize).centerCrop().into(view);
    }

    @Override
    public void loadGifImage(Context context, int resizeX, int resizeY, Drawable placeholder, ImageView view, Uri uri) {
        Glide.with(context).load(uri).asGif().placeholder(placeholder).override(resizeX, resizeY).into(view);
    }
}
